import router from "./index";
import Vue from "vue";
import store from "../store";

router.beforeEach((to, from, next) => {
  Vue.prototype.$qiankun.addSubRoutes(to, next, from, router, store, loadView);
  // 如果是需要登录的页面并且已经登陆了
  next();
});
// eslint-disable-line
router.afterEach(() => {
  // 关闭加载提示
  // store.dispatch('changeLoad', false)
});

const loadView = (view) => {
  // 路由懒加载
  return () => Promise.resolve(require(`@/views${view}.vue`).default);
};
